package com.atguigu02.catchthrowfinally;

import org.junit.Test;

public class FinallyTest {
    @Test
    public void Test(){
        System.out.println("hello");
    }

    @Test
    public void test2(){
        int[] arr=new int[]{-1,0,3,5,9,12};
        //int target=arr[0];
        int low=0;
        int high=arr.length-1;
        int mid=(low+high)/2;
        int target=9;
        while(low<=high){
            if(target>arr[low]&&target<arr[mid]){
                high=mid;
                mid=(low+high)/2;
            }
            if(target>arr[mid]&&target<arr[high]){
                low=mid;
                mid=(low+high)/2;
            }
            if(arr[mid]==target){
                System.out.println(mid);
                break;
            }
        }

    }

}
